
#ifndef _MEMBER_BGRAPHICITEM_H_
#define _MEMBER_BGRAPHICITEM_H_

#include <BGraphicWidget>
#include <BGraphicItem>
#include "IRound.h"

#define item_member(item)		((member_BGraphicItem*)((BGraphicItem*)item)->_ptr)

namespace BWE
{
	class member_BGraphicItem 
	{
		friend class BGraphicItem;
	public:
		member_BGraphicItem(BGraphicItem* graphicItem);
		~member_BGraphicItem();

		void raiseDirty();
		void raiseSignal(int signal, const BValue& value = BValue());

		void dispenseUpperStyles(BGraphicItem* upper);
		void dispenseStyles(BEvent& event);
		void applyStyle();
		void applyRoundStyle();

		void attach(BGraphicWidget* graphic);
		void detach(BGraphicWidget* graphic);

		void dirtyCell();
		void freshRects();
		void adjustRect(const BPointf& offset);

		void paint(BPainter& painter);
		void event(const BEvent& event);

		BGraphicItem*		boss;
		BGraphicWidget*		graphic;
		BGraphicItem*		parent;
		bool				visible;
		bool				refresh;
		bool				focusable;
		bool				focused;
		bool				selected;
		bool				hovered;
		bool				pressed;
		BWidgetHolder		widget;
		BString				tips;

		bool				dirtyStyle;
		BHolder<BStyle>		style;
		BHolder<BStyle>		realStyle;
		BColor				background;
		BColor				foreground;

		bool				dirty;
		BPointf				pos;
		BSizef				size;
		float				rotate;
		float				border;
		BPerchf				perch;
		BMarginf			margin;
		Align				originAlign;

		BHolder<IRound>		round;
		BRectf				area;
		BRectf				rect;
		BRectf				rectBack;
		BRectf				rectTitle;
		BRectf				rectTop;
		BRectf				rectLeft;
		BRectf				rectRight;
		BRectf				rectBottom;
		BRectf				rectCenter;
		BRectf				rectLeftTop;
		BRectf				rectLeftBottom;
		BRectf				rectRightTop;
		BRectf				rectRightBottom;

		BArray<BGraphicItemHolder>	children;

	};
}

#endif
